package q145_postorderTraversal;

import CommonClass.Common.TreeNode;

import java.util.ArrayList;
import java.util.List;
public class Solution_1 {
    private List<Integer> res = new ArrayList<>();
    public List<Integer> postorderTraversal(TreeNode root) {
        if (root == null){
            return res;
        }

        dfs(root, res);
        return res;
    }

    void dfs(TreeNode root, List res){
        if (root == null){
            return;
        }
        dfs(root.left, res);
        dfs(root.right, res);
        res.add(root.val);
    }
}
